from mock.MarkCopyHeap import Heap as MarkCopyHeap
from mock.MarkSweepHeap import Heap as MarkSweepHeap
from mock.ReferenceCountHeap import Heap as ReferenceCountHeap
from mock.MarkZipHeap import Heap as MarkZipHeap


def markCopyHeap():
    print("标记复制")
    heap = MarkCopyHeap(1024)
    n0 = heap.newObject(12, "aa")
    heap.addToRoot(n0)
    heap.gc()
    print(heap)


def referCountHeap():
    print("引用计数法")
    heap = ReferenceCountHeap(1024)
    n0 = heap.newObject(12, "aa")
    print(heap)
    heap.unReference(None, n0)
    print(heap)


def markSweepHeap():
    print("标记清除法")
    heap = MarkSweepHeap(1024)
    heap.newObject(12, "aaaa")
    print(heap)
    heap.gc()
    print(heap)


def markZipHeap():
    print("标记压缩法")
    heap = MarkZipHeap(1024)
    a = heap.newObject(12, "a")
    b = heap.newObject(12, "b")
    c = heap.newObject(12, "c")
    heap.addToRoot(a)
    heap.addToRoot(c)
    print(heap)
    heap.gc()
    print(heap)


if __name__ == '__main__':
    markCopyHeap()
    referCountHeap()
    markSweepHeap()
    markZipHeap()

